package com.yq.news.controller;

import com.yq.news.pojo.Category;
import com.yq.news.pojo.News;
import com.yq.news.service.FeignService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;

import java.util.List;

//@RestController
@Controller
public class FeignController {
    @Autowired
    private FeignService feignService;
    //新闻信息
    @RequestMapping(value = "/getNewsList")
    public ModelAndView getNewsList(){
        ModelAndView modelAndView = new ModelAndView();
        //查询新闻列表
        List<News> newsList = this.feignService.getNewsList();
        //查询新闻分类
        List<Category> categoryList = this.feignService.getCategoryList();
        modelAndView.addObject("newsList",newsList);
        modelAndView.addObject("categoryList",categoryList);
        modelAndView.setViewName("newslist");
        return modelAndView;
    }
//    //新闻分类信息
//    @RequestMapping(value = "/getCategoryList")
//    public List<Category> getCategoryList(){
//
//        return this.feignService.getCategoryList();
//    }
}
